<script>
	function change_type(){
		var type = $("#type").val();
		if (type == "upload"){
			$("tr.youtube").hide();
			$("tr.upload").show();
		} else {
			$("tr.upload").hide();
			$("tr.youtube").show();
		}
	}
	
	$(function(){
		$.get('/user/assets/moods/', function(data){
			for (var i=0;i < data.length;i++){
				var _html = "<option value='" + data[i][0] 
				+ "'>" + data[i][1] + "</option>";
				$("#moods").append(_html);
			}
		});
	});
</script>
<form enctype="multipart/form-data" method="post" action="" id="upload_asset">
	<table>
		<tr>
			<td><strong>Type:</strong></td>
			<td><select name="type" id="type" onchange="change_type();">
				<option value='upload'>Upload file</option>
				<option value='youtube'>Youtube video</option>
			</select></td>
		</tr>
		<tr>
			<td><strong>Title:</strong></td>
			<td><input id="new_asset_title" name="title" /></td>
		</tr>
		<tr>
			<td><strong>Description:</strong></td>
			<td><textarea id="new_asset_text"  name="text"></textarea></td>
		</tr>
		<tr class="upload">
			<td><strong>Chose File:</strong></td>
			<td><input type="file" id="new_asset_file" name="asset" /></td>
		</tr>
		<tr class="youtube" style="display:none">
			<td><strong>URL:</strong></td>
			<td><input id="youtube_url" name="youtube_url" /></td>
		</tr>
		<tr>
			<td><strong>Moods</strong></td>
			<td><select name="moods" id="moods">
				<option value="-1">Please select</option>
			</select></td>
		</tr>
	</table>
</form>